﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Smartec.Accounts.Camel.AMS.Model.Entities;
using Smartec.Accounts.Camel.AMS.Model.Repository;

namespace Smartec.Accounts.Camel.AMS.Model.Facades
{
   public static class TopicFacade
    {
       public static void AddTopic(Topic topic)
       {
           TopicRepository.AddTopic(topic);
          
       }

       public static List<Topic> GetAllTopics()
       {
           return TopicRepository.All();
       }

       public static Topic GetTopicById(int id)
       {
           return TopicRepository.All().FirstOrDefault(t=>t.ID==id);
       }
       public static void Save()
       {
           TopicRepository.Save();
       }
       public static void UpdateTopic(Topic topic)
       {
           var _topic = GetTopicById(topic.ID);
           _topic.SystemName = topic.SystemName;
           _topic.Body = topic.Body;
       }

       public static void DeleteTopicById(int id)
       {
           TopicRepository.DeleteTopicById(id);
       }

       public static Topic GetTopicByName(string topicName)
       {
           return TopicRepository.All().FirstOrDefault(t => t.SystemName.ToLower().Equals(topicName));
       }
    }
}
